
package com.wake.widget.skin.handler;

import android.content.res.ColorStateList;
import android.view.View;

import com.wake.widget.layout.INMUILayout;
import com.wake.widget.skin.NMUISkinHelper;
import com.wake.widget.widget.NMUIRadiusImageView;
import com.wake.widget.widget.NMUISlider;
import com.wake.widget.widget.roundwidget.NMUIRoundButton;

import org.jetbrains.annotations.NotNull;

public class NMUISkinRuleBorderHandler extends NMUISkinRuleColorStateListHandler {

    @Override
    protected void handle(@NotNull View view, @NotNull String name, ColorStateList colorStateList) {
        if(colorStateList == null){
            return;
        }
        if (view instanceof INMUILayout) {
            ((INMUILayout) view).setBorderColor(colorStateList.getDefaultColor());
        } else if (view instanceof NMUIRadiusImageView) {
            ((NMUIRadiusImageView) view).setBorderColor(colorStateList.getDefaultColor());
        } else if (view instanceof NMUIRoundButton) {
            ((NMUIRoundButton) view).setStrokeColors(colorStateList);
        } else if(view instanceof NMUISlider.DefaultThumbView){
            ((NMUISlider.DefaultThumbView)view).setBorderColor(colorStateList.getDefaultColor());
        }else{
            NMUISkinHelper.warnRuleNotSupport(view, name);
        }
    }
}
